import {getRemoteUserInfo, updateWXInfo} from '../../api/index'

Page({
  data: {
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  onShow () {
  },
  bindGetUserInfo (e) {
    let _userInfo = e.detail.userInfo
    if (_userInfo) {
      getRemoteUserInfo().then(res => {
        updateWXInfo(_userInfo.nickName, _userInfo.avatarUrl)
        wx.navigateBack()
        wx.hideLoading()
      })
    } else {
      wx.redirectTo({
        url: '/pages/index/open-setting'
      })
    }
  }
})
